package com.hackerrank.www.javap.Strings;

import java.util.Scanner;
import java.util.regex.Pattern;

/**
 * Created by 27340 on 2017/5/24.
 */
public class RexIP {
    public static void main(String[] args){
        String pattern = "((\\d|\\d\\d|[0-1]\\d\\d|2[0-4][0-9]|25[0-5])\\.){3}(\\d|\\d\\d|[0-1]\\d\\d|2[0-4][0-9]|25[0-5])";
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            String IP = in.next();
            System.out.println(Pattern.matches(pattern, IP));
        }

    }
}
